# Contributor: Chloe Kudryavtsev <toast@toastin.space>
# Maintainer: Chloe Kudryavtsev <toast@toastin.space>
pkgname=sd
pkgver=0.7.5
pkgrel=0
pkgdesc="An intuitive find & replace CLI"
url="https://github.com/chmln/sd"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le" # limited by rust/cargo
license="MIT"
options="net"
makedepends="cargo"
source="$pkgname-$pkgver.tar.gz::https://github.com/chmln/sd/archive/v$pkgver.tar.gz"
subpackages="$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"

export CARGO_HOME="$srcdir"/cargo

build() {
	cargo build \
		--release \
		--verbose
}

check() {
	cargo test --all \
		--release \
		--verbose
}

package() {
	install -Dm755 target/release/"$pkgname" "$pkgdir"/usr/bin/"$pkgname"

	# doc
	find target/release -name "$pkgname.1" \
		-exec install -Dm644 {} "$pkgdir"/usr/share/man/man1/"$pkgname.1" \;

	# comp
	find target/release -name "$pkgname.bash" \
		-exec install -Dm644 {} "$pkgdir"/usr/share/bash-completion/completions/"$pkgname" \;
	find target/release -name "$pkgname.fish" \
		-exec install -Dm644 {} "$pkgdir"/usr/share/fish/completions/"$pkgname.fish" \;
	find target/release -name "_$pkgname" \
		-exec install -Dm644 {} "$pkgdir"/usr/share/zsh/site-functions/"_$pkgname" \;
}

sha512sums="a51a7eb43111ec97c36a23d83ca7dc85d4c476b31b100c0625bf5742da0cafd28ff9cb8dec3481f0108b44eaecfddc9d95d93b79557b7a4ab2431daa703cdad2  sd-0.7.5.tar.gz"
